package insight;

import java.util.Iterator;

/*
    @author TTDB
    @create 2025/8/27
*/public class LinkList<E> implements List<E>{
    private Node<E> head;
    private Node<E> tail;
    private int size;
    class Node<E>{
        E element;
        Node<E> next;
        public Node(E element, Node<E> next)
        {
            this.element = element;
            this.next = next;
        }
    }
    @Override
    public void add(E element) {
        Node<E> newNode = new Node<>(element, null);
        if(head == null){
            head = newNode;
            tail = newNode;
        }else{
            tail.next = newNode;
            tail = newNode;
        }
        size++;
    }

    @Override
    public void add(int index, E element) {
        if(index < 0 || index > size) throw new IndexOutOfBoundsException();
        int i = 0;
        Node<E> current = head;
        while(current != null && i < index){
            current = current.next;
            i++;
        }
        Node<E> newNode = new Node<>(element, current.next);
        current.next = newNode;
        size++;
    }

    @Override
    public E remove(int index) {
        return null;
    }

    @Override
    public boolean remove(E element) {
        return false;
    }

    @Override
    public E get(int index) {
        return null;
    }

    @Override
    public int size() {
        return 0;
    }

    @Override
    public E set(int index, E element) {
        return null;
    }

    @Override
    public Iterator<E> iterator() {
        return null;
    }
}
